var UId = getParameter("UId");
// var sessionData = getParameter("sessionData");
$(function() {
	/*
	 * var urlStr = serverPath + "/server/entryQuestionnaire.do"; var jsonStr =
	 * '{method:"getUidBySession",sessionData:' + sessionData + '}';
	 * UseAjax(urlStr, jsonStr, document.cookie, rt, '1');
	 */
	/*
	 * var i = 0; function I(){ i++; if(i>=100){ i=1; } return '-' + i; }
	 */
	rt();
});
var now = new Date();
function rt() {
	// var date = format(now);
	charts("container", now);
};

function charts(name, date) {
	$('#' + name + '').highcharts(
			{

				// chart : {
				// type : 'line',
				// // type : 'spline',
				// // zoomType:'xy'
				// },
				title : {
					text : ''
				},
				subtitle : {
					text : '全天'
				},
				xAxis : {
					type : 'datetime',
					dateTimeLabelFormats : {
						// millisecond: '%H:%M:%S.%L',
						// second: '%H:%M:%S',
						// minute: '%H:%M',
						// hour: '%H:%M',
						day : '%m-%d',
					// week: '%e. %b',
					// month: '%b \'%y',
					// year: '%Y'
					},
					min : Date.UTC(date.getFullYear(), date.getMonth(), date
							.getDate() - 3),
					max : Date.UTC(date.getFullYear(), date.getMonth(), date
							.getDate() + 3),
					/*
					 * step: 4, formatter: function () { return
					 * Highcharts.dateFormat('%Y-%b-%e', this.value); },
					 */
					/*
					 * labels: { step:2 },
					 */
					maxPadding : 5,
					gridLineWidth : 1,
					gridLineDashStyle : 'Dash',// 样式 虚线

				// categories: dates
				},
				yAxis : {
					labels : {
						step : 2
					},
					tickPixelInterval : 3,
					// tickInterval: 5,
					// tickWidth:1,//刻度的宽度 突出的线的宽
					min : 0, // 固定列最小值
					max : 33.3,
					// max : 20,
					// minTickInterval:1,
					// tickPositions: [1.1, 2.5, 5.0, 6.0, 7.0, 8.0, 9.0, 11.0,
					// 15.0, 33.3], // 指定竖轴坐标点的值
					title : {
						enabled : false,
					} /*
						 * ,plotLines: [{ value: 0,//標示線 width: 1, color:
						 * '#808080' }]
						 */
					,
					plotBands : [ {// 标示区域
						from : 5.0,
						to : 14.0,
						color : '#E1F9CE',
					/*
					 * label : [ { text : '不显示', style : { color : 'blue',
					 * fontWeight : 'bold' } } ]
					 */
					} ],
				/*
				 * labels: { step:1 }
				 */
				},
				tooltip : {
					// enabled : false,
					formatter : function() {
						// return '<b>'+ this.series.name +'</b><br>'+this.x +':
						// '+ this.y +'°C';
						return 'ceshi';
						/*
						 * return '<br/>' + Highcharts.dateFormat('%e. %b',
						 * this.x) + ': ' + this.y + ' ';
						 */
					}
				},
				plotOptions : {
					line : {
						dataLabels : {
							enabled : true
						},
						enableMouseTracking : false
					}
				},
				credits : {
					enabled : false
				},
				legend : {
					enabled : false
				/*
				 * layout: 'vertical',提示框 align: 'right', verticalAlign:
				 * 'middle', borderWidth: 0
				 */
				},
				series : [ {
					// pointStart : Date.UTC(2015, 8, 1),
					// pointStart : (getLastDay(date, 3)),
					// tickInterval: 24 * 3600 * 1000,
					// pointInterval : 24 * 3600 * 1000, // one day
					pointPadding : 0,// 数据点之间的距离值
					groupPadding : 0,// 分组之间的距离值
					name : null,
					// endOnTick:true,是否强制轴线在标线处结束
					// data : [0,1,2,4,5,null,4]
					data : [ [ Date.UTC(2015, 7, 4), 0 ],
							[ Date.UTC(2015, 7, 5), 2 ],
							[ Date.UTC(2015, 7, 6), 3 ],
							[ Date.UTC(2015, 7, 7), 0 ],
							[ Date.UTC(2015, 7, 9), 2 ],
							[ Date.UTC(2015, 7, 10), 3 ],
							[ Date.UTC(2015, 7, 12, 13), 11 ],
							[ Date.UTC(2015, 7, 12, 15), 7 ],
							[ Date.UTC(2015, 7, 13), 2 ],
							[ Date.UTC(2015, 7, 16), 1 ],
							[ Date.UTC(2015, 7, 17, 13), 11 ],
							[ Date.UTC(2015, 7, 18, 15), 7 ],
							[ Date.UTC(2015, 7, 19), 2 ],
							[ Date.UTC(2015, 7, 20), 1 ] ]

				// [ Date.UTC(2015, 8, 4), 0 ]
				} ]
			});
}

$(function() {
	// swipe 的dome
	$("#container").swipe(
			{
				swipeLeft : function(event, direction, distance, duration,
						fingerCount) {

					now = getNextDay(now, 7);
					charts("container", now);
				},
				swipeRight : function(event, direction, distance, duration,
						fingerCount) {
					now = getLastDay(now, 7);
					charts("container", now);
				},
			});

});
function getNextDay(d, i) {
	d = new Date(d);
	d = +d + 1000 * 60 * 60 * 24 * i;
	d = new Date(d);
	return d;

}
function getLastDay(d, i) {
	d = new Date(d);
	d = +d - 1000 * 60 * 60 * 24 * i;
	d = new Date(d);
	return d;
}
// 获取url参数
function getParameter(param) {
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
}